package com.darren.befriend.fragments;

import java.util.ArrayList;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.View;

import com.darren.befriend.BaseActivity;
import com.darren.befriend.HomeActivity;
import com.darren.befriend.R;
import com.darren.befriend.UserSettingInitialActivity;
import com.darren.befriend.constants.Constant;

public class MusicFragment extends HobbyBaseFragment {
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		interestTextArr = getResources().getStringArray(R.array.music_text_arr);
		mInterestResIds = new int[] { R.drawable.m0, R.drawable.m1,
				R.drawable.m2, R.drawable.m3, R.drawable.m4, R.drawable.m5,
				R.drawable.m6, R.drawable.m7, R.drawable.m8, R.drawable.m9,
				R.drawable.m10, R.drawable.m11, R.drawable.m12, R.drawable.m13,
				R.drawable.m14, R.drawable.m15, R.drawable.m16, R.drawable.m17,
				R.drawable.m18, R.drawable.m19, R.drawable.m20, R.drawable.m21,
				R.drawable.m22, R.drawable.m23, R.drawable.m24, R.drawable.m25,
				R.drawable.m26, R.drawable.m27, R.drawable.m28, R.drawable.m29,
				R.drawable.m30 };
		if (getArguments() != null) {
			MODE_VALUE = getArguments().getInt(MODE, 0);
		}
	}

	@SuppressWarnings("unchecked")
	@Override
	public void onActivityCreated(Bundle savedInstanceState) {

		mCurrentUser = ((BaseActivity) getActivity()).getCurrentUser();
		if (mCurrentUser != null) {

			mSelected = (ArrayList<Boolean>) mCurrentUser.get("MUSIC");
		}

		super.onActivityCreated(savedInstanceState);
		mTitle = getString(R.string.music);
		if (getActivity() instanceof UserSettingInitialActivity) {
			((UserSettingInitialActivity) getActivity())
					.setActivityTitle(mTitle);
			if (MODE_VALUE == FIRST_MODE) {
				((UserSettingInitialActivity) getActivity())
						.setNavigationImage(R.drawable.item_film_b,
								R.drawable.item_me);
			} else if (MODE_VALUE == SECOND_MODE) {
				((UserSettingInitialActivity) getActivity())
						.setNavigationImage(R.drawable.item_back,
								Integer.MAX_VALUE);
			}
		} else if (getActivity() instanceof HomeActivity) {
			((HomeActivity) getActivity()).showRightButtonImg(false);
			((HomeActivity) getActivity()).setLeftImage(R.drawable.item_back);
			((HomeActivity) getActivity()).setActivityTitle(mTitle);
		}
	}

	@Override
	public void onClick(View v) {
		HOBBY_TYPE = Constant.MUSIC;
		super.onClick(v);
	}

	public static Fragment create(int mode) {
		MusicFragment fragment = new MusicFragment();
		Bundle bundle = new Bundle();
		bundle.putInt(MODE, mode);
		fragment.setArguments(bundle);
		return fragment;
	}
}
